package com.wujunshen.designpattern.creational.factory.simplefactory.instance;

import com.wujunshen.designpattern.creational.factory.IVehicle;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author frank woo(吴峻申) <br>
 *     email:<a href="mailto:frank_wjs@hotmail.com">frank_wjs@hotmail.com</a> <br>
 * @date 2021/8/10 16:55<br>
 */
public class SimpleFactory {
  private static final Map<Integer, IVehicle> registerProductMap = new ConcurrentHashMap<>();

  public static void registerProduct(int brandCode, IVehicle vehicle) {
    registerProductMap.put(brandCode, vehicle);
  }

  public static IVehicle createProduct(int brandCode) {
    return registerProductMap.get(brandCode);
  }
}
